<?php
	//$userid = $_userid;
	$_userid = $_userid == 1 && $userid  ? $userid : $_userid; // 管理员编辑其他会员信息权限
	
	switch($action){
		case 'manage':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			require_once 'form.class.php';
			require_once 'includes/guestbook.class.php';
			$c = new guestbook();
			$c->set_userid($userid);
			// common
			
			$infos = $c->listinfo("WHERE userid='$userid'",'`gid` DESC',$page);
			$pages = $c->pages;
			include template('guestbook_manage.html','yellowpage');
		break;
		
		case 'answer':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			require_once 'form.class.php';
			require_once 'includes/guestbook.class.php';
			$c = new guestbook();
			$c->set_userid($userid);
			// common
			
			if($dosubmit)
			{
				$style = htmlspecialchars($style);
				
				$c->sign($id,$style);
				showmessage('操作成功！',$forward);
			}
			else
			{
				$info = $c->get($id);
				$c->status($id);
				if($info['id'] && in_array($info['label'],array('product','buy','job','news')))
				{
					$table = DB_PRE.'yellowpage_'.$info['label'];
					$r = $db->get_one("SELECT `title` FROM `$table` WHERE `id`='$info[id]'");
					$title = $r['title'];
				}
			}
			include template('guestbook_answer.html','yellowpage');
		break;
	
		case 'delete':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			require_once 'form.class.php';
			require_once 'includes/guestbook.class.php';
			$c = new guestbook();
			$c->set_userid($userid);
			// common
			
			$c->delete($gid);
			$infos = $c->listinfo("WHERE userid='$userid'",'`gid` DESC',$page);
			$pages = $c->pages;
			$action = 'manage';
			include template('guestbook_manage.html','yellowpage');
		break;
		
		case 'batdo':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			require_once 'form.class.php';
			require_once 'includes/guestbook.class.php';
			$c = new guestbook();
			$c->set_userid($userid);
			// common
			
			foreach($gid as $id)
			{
				if($batmethod == 'delete')
				{
					if($id)$c->delete(intval($id));
				}
				elseif($batmethod == 'bookmark')
				{
					if($id)$c->status(intval($id));
				}
			}
			exit('ok');
			include template('guestbook_manage.html','yellowpage');
		break;
	}
?>